using System;

namespace Entities
{
	public class IdleAction : MobAction
	{
		public IdleAction ()
		{
			type = TypeAction.idle;
		}
		
		public override MobAction nextAction(Mob mob, Fighter target){
			if (target.distance(mob) <= attackrange){
				return new AttackAction();
			}
			
			if (mob.isLeader()){
				if (mob.distanceAway() > minbackrange){
					return new BackAction();
				}
			} else {
				if (mob.getLeader().distance(mob) > minfollowrange){
					return new FollowAction();
				}
			}
			
			if (target.distance(mob) > attackrange && mob.distance(target) < maxchaserange){ //start chase
				return new ChaseAction();
			}
			
			Mob other = mob.isBlocking();
			if (other != null){
				return new ClearAction(other);
			}
			
			return new IdleAction();
		}
	}
}

